//
//  PKLeftViewController.m
//  PianKe
//
//  Created by lanou on 15/9/25.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKLeftViewController.h"
#import "PKRightViewController.h"
#import "PKLeftView.h"
@interface PKLeftViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) PKRightViewController *rightVC;
@property(nonatomic,strong) UITableView *mainListTableView;//主列表
@property(nonatomic,strong) NSArray *dataSourceArray;//提供数据源
@property(nonatomic,strong) PKLeftView *PkLeftViewHeader;
@end

@implementation PKLeftViewController
-(NSArray *)dataSourceArray
{
    if (_dataSourceArray==nil
) {
        self.dataSourceArray=@[@"分组",@"良品",@"电台",@"读者"];
    }
    return _dataSourceArray;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
  
        //ARC和MRC都不能手动调用dealloc方法，只能重写，ARC重写的时候不能在dealloc方法内部调用[super dealloc]，一般会用移除观察者，代理对象设置空等
        //ARC里面，编译器（LLVM）会自动伴我们添加release代码，添加的时机就是这个对象出作用域的时候，所以我们的工程编译成二进制文件的时候还是有release代码的。只不过我们没有写，看不到
    
    NSLog(@"12353467");
  _mainListTableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, SCREEN_HEIGHT-280) style:    UITableViewStylePlain];
    _mainListTableView.delegate=self;
    _mainListTableView.dataSource=self;
    _mainListTableView.tableFooterView=[[UITableView alloc]initWithFrame:CGRectZero];
    [_mainListTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
  self.PkLeftViewHeader =[[PKLeftView  alloc]initWithFrame:CGRectMake(10, 20, SCREEN_WIDTH-20, 180)];
    [self.view addSubview:self.PkLeftViewHeader];
    
    [self.view addSubview:_mainListTableView];
    self.view.backgroundColor=[UIColor greenColor];
    self.rightVC=[[PKRightViewController alloc]init];
    [self.view addSubview:self.rightVC.view];
    

   
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
    NSString *text1=self.dataSourceArray[indexPath.row];

    cell.textLabel.text=text1;
    return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
    return self.dataSourceArray.count;
}
#warning 1-2UITableViewDelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_rightVC changeViewWithIndex:indexPath.row];
//    UIView *view =    [[NSClassFromString(@"UIView") alloc]init];
//    view.frame=CGRectMake(0, 0, 100, 100);
//    view.backgroundColor=[UIColor blackColor];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
